package com.hxht.cmp.module;


import com.hxht.cmp.common.Constants;
import com.hxht.cmp.service.CasePlanService;
import com.hxht.cmp.service.CourtStatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/system_monitor")
public class SystemModule {

    @Autowired
    private CourtStatusService courtStatusService;
    @Autowired
    private CasePlanService casePlanService;

    /**
     * 直播页面
     *
     * @param planUid
     * @param vlcCourtUid
     * @param courtRoomUid
     * @param channel
     * @return
     */
    @RequestMapping("/panel_living")
    public ModelAndView toPanelLiving(String planUid, String vlcCourtUid, String courtRoomUid, String channel) {
        ModelAndView modelAndView = new ModelAndView();
        Map<String, Object> caseMap = casePlanService.getCaseInfoByUid(planUid);
        //将页面中需要的参数携带回去
        modelAndView.addObject("serviceIp", Constants.COURTROOM_MAP.get(courtRoomUid).getDeviceIp());
        modelAndView.addObject("courtRoomUid", courtRoomUid);
        modelAndView.addObject("vlcCourtUid", vlcCourtUid);
        modelAndView.addObject("channel", channel);
        modelAndView.addObject("planUid", planUid);
        modelAndView.addObject("caseMap", caseMap);
        modelAndView.setViewName("play/living");
        return modelAndView;
    }

    /**
     * 点播页面
     *
     * @return
     */
    @RequestMapping("/panel_play")
    public ModelAndView panelPlay(String planUid) {
        ModelAndView modelAndView = new ModelAndView();
        Map<String, Object> caseMap = casePlanService.getCaseInfoByUid(planUid);
        modelAndView.addObject("caseMap", caseMap);
        modelAndView.setViewName("play/play");
        return modelAndView;
    }

    /**
     * 法庭状态
     *
     * @param courtUid
     * @return
     */
    @RequestMapping("/sys_court_status")
    public ModelAndView systemCourtStatus(String courtUid) {
        ModelAndView modelAndView = new ModelAndView();
        List<Map<String, Object>> statusList = courtStatusService.selectCourtStatusList(courtUid);
        modelAndView.addObject("statusList", statusList);
        modelAndView.setViewName("panel/sys_court_status");
        return modelAndView;
    }

    /**
     * 报警信息
     *
     * @param courtUid
     * @return
     */
    @RequestMapping("/sys_warning_message")
    public ModelAndView systemWarningMessage(String courtUid) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("courtUid", courtUid);
        modelAndView.setViewName("panel/sys_warning_message");
        return modelAndView;
    }

    /**
     * 点播管理
     *
     * @return
     */
    @RequestMapping("/sys_play_info")
    public ModelAndView systemPlayInfo() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("panel/sys_play_info");
        return modelAndView;
    }

    /**
     * 日志信息
     *
     * @return
     */
    @RequestMapping("/sys_log_info")
    public ModelAndView systemLognfo() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("panel/sys_log_info");
        return modelAndView;
    }

    /**
     * 服务器状态
     * @return
     */
    @RequestMapping("/sys_server_status")
    public ModelAndView systemServerStatus() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("panel/sys_server_status");
        return modelAndView;
    }

}
